using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class VbatchdetMap : EntityTypeConfiguration<Vbatchdet>
    {
        public VbatchdetMap()
        {
            // Primary Key
            this.HasKey(t => new { t.VBTCHDET_ID, t.DATE, t.PERIOD, t.ACCT, t.CURRENCY, t.CSTCTRID, t.origin });

            // Properties
            this.Property(t => t.PostingType)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.VBTCHDET_ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.ID)
                .HasMaxLength(10);

            this.Property(t => t.INVC)
                .HasMaxLength(8);

            this.Property(t => t.PERIOD)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.BATCH)
                .HasMaxLength(8);

            this.Property(t => t.DESC)
                .HasMaxLength(130);

            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.SOURCE)
                .HasMaxLength(2);

            this.Property(t => t.CURRENCY)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.PVRV)
                .HasMaxLength(10);

            this.Property(t => t.SUBSOURCE)
                .HasMaxLength(3);

            this.Property(t => t.CHECK)
                .HasMaxLength(20);

            this.Property(t => t.INVREF)
                .HasMaxLength(6);

            this.Property(t => t.PAYREF)
                .HasMaxLength(6);

            this.Property(t => t.CSTCTRID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.SubDatabase)
                .HasMaxLength(50);

            this.Property(t => t.origin)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(2);

            this.Property(t => t.originnumber)
                .HasMaxLength(11);

            this.Property(t => t.sbatch)
                .HasMaxLength(8);

            this.Property(t => t.vbatchdet_Approval)
                .IsFixedLength()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("Vbatchdet");
            this.Property(t => t.PostingType).HasColumnName("PostingType");
            this.Property(t => t.VBTCHDET_ID).HasColumnName("VBTCHDET_ID");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.INVC).HasColumnName("INVC");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.DEBIT).HasColumnName("DEBIT");
            this.Property(t => t.CREDIT).HasColumnName("CREDIT");
            this.Property(t => t.PERIOD).HasColumnName("PERIOD");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.REVERSING).HasColumnName("REVERSING");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.SOURCE).HasColumnName("SOURCE");
            this.Property(t => t.MISCCASH).HasColumnName("MISCCASH");
            this.Property(t => t.DEBITDOL).HasColumnName("DEBITDOL");
            this.Property(t => t.CREDITDOL).HasColumnName("CREDITDOL");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.DEBITACCT).HasColumnName("DEBITACCT");
            this.Property(t => t.CREDITACCT).HasColumnName("CREDITACCT");
            this.Property(t => t.PAYERTYPE).HasColumnName("PAYERTYPE");
            this.Property(t => t.PVRV).HasColumnName("PVRV");
            this.Property(t => t.SUBSOURCE).HasColumnName("SUBSOURCE");
            this.Property(t => t.CHECK).HasColumnName("CHECK");
            this.Property(t => t.INVREF).HasColumnName("INVREF");
            this.Property(t => t.PAYREF).HasColumnName("PAYREF");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");
            this.Property(t => t.CLOSING).HasColumnName("CLOSING");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.JOBID).HasColumnName("JOBID");
            this.Property(t => t.SubDatabase).HasColumnName("SubDatabase");
            this.Property(t => t.Duedate).HasColumnName("Duedate");
            this.Property(t => t.Classification).HasColumnName("Classification");
            this.Property(t => t.origin).HasColumnName("origin");
            this.Property(t => t.originnumber).HasColumnName("originnumber");
            this.Property(t => t.batchid).HasColumnName("batchid");
            this.Property(t => t.sbatch).HasColumnName("sbatch");
            this.Property(t => t.vbatchdet_Posted).HasColumnName("vbatchdet_Posted");
            this.Property(t => t.vbatchdet_Approval).HasColumnName("vbatchdet_Approval");
            this.Property(t => t.vbatchdet_Selected).HasColumnName("vbatchdet_Selected");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.Vbatchdets)
                .HasForeignKey(d => d.ACCT);
            this.HasRequired(t => t.Cstctr)
                .WithMany(t => t.Vbatchdets)
                .HasForeignKey(d => d.CSTCTRID);
            this.HasRequired(t => t.Period1)
                .WithMany(t => t.Vbatchdets)
                .HasForeignKey(d => d.PERIOD);

        }
    }
}
